package com.huashi.codeUtil.entity;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;

import java.util.List;

/**
 * 分页查询参数
 */
@ApiModel(value = "PageRequest",description = "分页查询参数")
public class PageResponse<T> {

    private Long current;

    private Long pageSize;

    private Long total;

    private Long pages;

    private List<T> records;

    public PageResponse(){

    }

    public PageResponse(Long current,Long pageSize,Long pages,Long total,List<T> records){
        this.current =current;
        this.pages = pages;
        this.pageSize = pageSize;
        this.total = total;
        this.records = records;
    }

    public PageResponse(IPage<T> page,List<T> records){
        this.current =page.getCurrent();
        this.pages = page.getPages();
        this.pageSize = page.getSize();
        this.total = page.getTotal();
        this.records = records;
    }

    public PageResponse(IPage<T> page){
        this.current =page.getCurrent();
        this.pages = page.getPages();
        this.pageSize = page.getSize();
        this.total = page.getTotal();
        this.records = page.getRecords();
    }
    public Long getCurrent() {
        return current;
    }

    public void setCurrent(Long current) {
        this.current = current;
    }

    public Long getPageSize() {
        return pageSize;
    }

    public void setPageSize(Long pageSize) {
        this.pageSize = pageSize;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Long getPages() {
        return pages;
    }

    public void setPages(Long pages) {
        this.pages = pages;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    @Override
    public String toString() {
        return "PageResponse{" +
                "current=" + current +
                ", pageSize=" + pageSize +
                ", total=" + total +
                ", pages=" + pages +
                ", records=" + records +
                '}';
    }
}
